<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Vue属性监听</title>
</head>
<body>
  <div id="root"></div>

  <script src="https://unpkg.com/vue@next"></script> 
  <script>
    const app = Vue.createApp({
      data(){
        return{
          firstName: 'Hello',
          lastName: 'World',
          fullName: 'Hello World',
        };
      },
      // 属性监听
      watch: {
        firstName(val){
          this.fullName = val + this.lastName;
        },
        lastName(val){
          this.fullName = this.firstName + val;
        },
      },
      computed: {
        fullName(){
          return this.firstName + this.lastName;
        }
      },
      template: `<div>{{ fullName }}</div>`,
    });
    const vm = app.mount('#root')
  </script>
</body>
</html>